// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    catelist:["亚索","劲夫","就这","哈哈","芜湖","起飞","盲仔"],
    bannerlist:[{
      url:"../../images/banner1.jpg"
    },{
      url:"../../images/banner2.jpg"
    },{
      url:"../../images/banner3.jpg"
    }],
    danmulist:[{
        text:"网院",
        color:"#ff0000",
        time:5
      },{
        text:"电大",
        color:"#E64E69",
        time:10
      }]   
  },
  
  onLoad(){
  },
  saveUserInfo:function(){
    var data ={"name":"申海兵","student_id":"201965110429"}
    wx.setStorageSync('userinfo', data)
    //异步缓存
    wx.setStorage({
      key:"studentinfo",
      data: {"sex":"男","age":19}
    })
  },
  getUserInfo:function(){
    var studentunfo=wx.getAccountInfoSync('studentinfo');
    console.log(studentunfo);
    wx.getStorage({
      key: 'userinfo',
      success(res){
        console.log(res);
      }
    })
    wx.getStorageInfo({
      success: (option) => {
        console.log(option)
      },
    })
  },
  removeUserInfo:function(){
    //同步移除
    wx.removeStorage({
      key: 'userinfo',
    })
    wx.removeStorageSync('studentinfo');
 
  },
  getLocal:function(){
    var then =this;
    wx.getLocation({
      success(res){
        then.setData({
          latitude:res.latitude,
          longgittude:res.longitude
        })
      }
    })
  },
  openMap:function(){
    var then =this;
      wx.openLocation({
        type:"gjc02",
        latitude: then.data.latitude,
        longitude: then.data.longgittude,
        name:"湖南开放大学1104",
        address:"湖南省长沙市天心区青园路203-3"
      })
  },
  selectLocal:function(){
    var then =this;
wx.chooseLocation({
  latitude: then.data.latitude,
  longitude:then.data.longgittude
})
  },
  latitude:"",
    longgittude:"",
    call:function(){
wx.makePhoneCall({
  phoneNumber: '1008611',
})
    },
    scanCode:function(){
wx.scanCode({
  onlyFromCamera: true,
  success(res){
    console.log(res)
  }
})
    },

    
  checkboxChange:function(e){
    var then = this;
    var likestr = "";
    for (let index = 0; index<e.detail.value,length; index++){
likes =likestr+e.detail.value[index];
    }
    then.setData({
      likes:e.detail.value[0]
    })
    console.log(e)
    console.log(e.detail.value[0])
  },
})
